package com.gary.log.action;

import java.util.List;

import com.gary.core.action.ExtSupportAction;
import com.gary.core.orm.query.QueryFilter;
import com.gary.core.orm.utils.PageList;
import com.gary.core.util.SystemConstants;
import com.gary.log.logcore.LogItem;
import com.gary.log.service.ILogService;

import net.sf.json.JSONArray;

public class LogAction extends ExtSupportAction<LogItem> {

	private static final long serialVersionUID = 1L;
	
	private ILogService logService;
	@Override
	protected QueryFilter getQueryCondition() {
		return null;
	}
	@Override
	protected LogItem getObject() {
		return log;
	}
	
	@Override
	public ILogService getService() {
		return this.logService;
	}

	public void setLogService(ILogService service) {
		this.logService = service;
	}
	
	@SuppressWarnings("unchecked")
	public String listOperLog(){
		PageList lst=getPageList();
		List list = lst.getList();
		this.total = lst.getTotal();
		JSONArray array=JSONArray.fromObject(list);
		this.jsonString="{start:"+getStart()+",limit:"+getLimit()+",totalCount:"+this.total+",root:"+array.toString()+"}";
		return SystemConstants.OUTPUT_JSON_STR;
	}
	
	@SuppressWarnings("unchecked")
	public String listErrLog(){
		PageList lst=getPageList();
		List list = lst.getList();
		this.total = lst.getTotal();
		JSONArray array=JSONArray.fromObject(list);
		this.jsonString="{start:"+getStart()+",limit:"+getLimit()+",totalCount:"+this.total+",root:"+array.toString()+"}";
		return SystemConstants.OUTPUT_JSON_STR;
	}
	
	public LogItem log;
	
}